<template>
  <el-container class="root">
    <el-header style="">
      <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></el-avatar>
      <div class="line"></div>
      <el-menu
        :default-active="activeIndex+''"
        class="el-menu-demo"
        mode="horizontal"
        @select="handleSelect"
        background-color="#B3C0D1"
        text-color="#fff"
        active-text-color="#ffd04b">
        <el-menu-item index="1">处理中心</el-menu-item>
        <el-menu-item index="2">消息中心</el-menu-item>
        <el-menu-item index="3"><a href="https://www.ele.me" target="_blank">订单管理</a></el-menu-item>
      </el-menu>
    </el-header>
    <el-container>
      <!--左侧菜单-->
      <el-aside width="230px">
        <el-menu
          unique-opened
          router
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          background-color="#545c64"
          align="left"
          text-color="#fff"
          active-text-color="#ffd04b">
          <el-submenu :index="menu.title" v-for="(menu) in menus" :key="menu.title">
            <template slot="title">
              <i class="el-icon-menu"></i>
              {{menu.title}}
            </template>
            <el-menu-item :index="menu.path+item.path" v-for="item in menu.items" :key="item.path">
              {{item.title}}
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-main>
          <router-view/>
        </el-main>
        <el-footer>Footer</el-footer>
      </el-container>
    </el-container>
  </el-container>
</template>

<script>
  import menus from '../menu'

  export default {
    name: 'index',
    data () {
      const item = {
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄',
        menus: []
      }
      return {
        activeIndex: '1',
        tableData: Array(10).fill(item)
      }
    },
    computed: {},
    created () {
      this.menus = menus
    },
    methods: {
      handleOpen (key, keyPath) {
        console.log(key, keyPath)
      },
      handleClose (key, keyPath) {
        console.log(key, keyPath)
      },
      handleSelect (key, keyPath) {
        console.log(key, keyPath)
      }
    }
  }
</script>

<style scoped>
  .el-header {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: right;
  }

  .root {
    width: 100%;
    height: 917px;
  }

  .el-header, .el-footer {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  .el-aside {
    background-color: #545c64;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-main {
    color: #333;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
</style>
